package com.net.xpay.core.dao;

import com.net.xpay.core.domain.PayTransBatch;
import com.net.xpay.core.dto.AccountAmountCountDto;
import com.net.xpay.core.model.*;
import com.net.common.annotation.DataShard;
import com.net.common.dao.Page;
import com.net.common.dao.VersionedMapper;
import com.net.xpay.core.model.PayTransDailyStatModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@DataShard("")
@Repository
public interface PayTransBatchMapper extends VersionedMapper<Long, PayTransBatch> {
    List<PayTransBatch> search(@Param("searchModel") PayTransBatchSearchModel searchModel, @Param("page") Page page);

    long searchCount(@Param("searchModel") PayTransBatchSearchModel searchModel);

    List<PayTransBatch> list(@Param("searchModel") PayTransBatchSearchModel searchModel);

    PayTransBatchStatResultModel statLevelOneSuccessPayTransBatch(@Param("partnerId") Long partnerId, @Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    PayTransBatchStatResultModel statLevelTwoSuccessPayTransBatch(@Param("partnerId") Long partnerId, @Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    UserTransStatModel countAmountAndTimesOfSuccess(@Param("userId")Long userId, @Param("dayStart") LocalDateTime dayStart, @Param("dayEnd") LocalDateTime dayEnd);

    /**
     * 查询当天的支付宝转账额度
     */
    BigDecimal getTransferLimit(@Param("minEndTime")LocalDateTime minEndTime,
                                @Param("maxEndTime")LocalDateTime maxEndTime,
                                @Param("userId")Long userId,
                                @Param("alipayUserId")Long alipayUserId);

    /**
     * 公司日账单数据统计
     */
    CompanyBillDailyStatModel statDailyCompanyBill(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    UserPayTransStatCommonModel countNoFreeAmountAndTimesOfSuccess(@Param("userId")Long userId, @Param("dayStart") LocalDateTime dayStart, @Param("dayEnd") LocalDateTime dayEnd);

    PartnerUserPayTransDayStatModel sumPartnerUserPayTransDay(@Param("userId")Long userId,@Param("minEndTime") LocalDateTime minEndTime,@Param("maxEndTime") LocalDateTime maxEndTime);

    PartnerUserPayTransDayStatModel sumPartnerPayTransDay(@Param("partnerId")Long partnerId,@Param("minEndTime") LocalDateTime minEndTime,@Param("maxEndTime") LocalDateTime maxEndTime);

    PayTransDailyStatModel statActivePartnerCount(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    CompanyPayTransDayStatModel sumCompanyPayTransDay(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long sumTotalVeryAlipayUserCount(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long sumUserTotalVeryAlipayUserCount(@Param("userId")Long userId,@Param("minEndTime") LocalDateTime minEndTime,@Param("maxEndTime") LocalDateTime maxEndTime);

    List<Long> listIds(@Param("searchModel") PayTransBatchSearchModel searchModel);

    AccountAmountCountDto sumTransSuccessAmount(@Param("userId") Long userId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("dayTime") LocalDateTime dayTime);
}
